home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 January - Disc 2 / Macworld (1999-01) (Disk 2).dmg / Shareware World / Utilities / User Interface / FinderPop175 / FinderPoplets / Source&API / FinderPopAPI.h < prev    next >
Encoding:
Text File  |  1998-10-13  |  5.7 KB  |  170 lines  |  [TEXT/CWIE]

  1. //=====================================================================================
  2. //    File:        FinderPopAPI.h
  3. //
  4. //    Contains:    FinderPop Application Programming Interface
  5. //
  6. //    Written by:    turly o’connor, cork, ireland        turly@geocities.com
  7. //
  8. //    Copyright:    1997, 1998 by Turlough O'Connor, all rights reserved.
  9. //
  10. //    Change History (most recent first):
  11. //        <02>    18-Sep-98    tur        Add Beta version of FinderPoplets.  Haven't tried
  12. //                                    it myself yet!
  13. //        <01>    31-Aug-98    tur        Make Beta Version publicly available.
  14. //
  15. //=====================================================================================
  16.  
  17. #ifndef    __FinderPop__
  18. #define    __FinderPop__
  19.  
  20. #include <Events.h>
  21. #include <Processes.h>
  22. #include <AppleEvents.h>
  23.  
  24. #if PRAGMA_ALIGN_SUPPORTED
  25. #pragma options align=mac68k
  26. #endif
  27.  
  28. enum {
  29.     kFinderPopAPIGestaltSignature = 'FpoP',
  30.     kFinderPopletFileType = 'Fplt',
  31.     kFinderPopletRsrcType = 'Fplt',
  32.     kFinderPopletRsrcID = 128,
  33.  
  34.     uppFinderPopAPIProcInfo = kPascalStackBased
  35.          | RESULT_SIZE(SIZE_CODE(sizeof(SInt32)))
  36.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(UInt32)))
  37.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(SInt32)))
  38.  
  39. };
  40.  
  41. //
  42. // for FinderPoplets™... 68K SysHeap 'Fplt' ID=128 resource, just jumped to
  43. // with TFinderPopletInfo parameter.  Filetype should be kFinderPopletFileType.
  44. //
  45. // Handy for things like "Show Finder and Hide Others", which so many people have
  46. // requested it’s driving me nuts!
  47. //
  48. // 'Fplt' routine can return one of:
  49.  
  50. enum {
  51.         kFinderPopletDetachAndStayResident = 1,        // SysHeap 'Fplt' rsrc is detached and the 'Fplt' file is closed; 
  52.                                                     // bu detached Fplt code rsrc continues to be called
  53.  
  54.         kFinderPopletTerminate,                        // if 'Fplt' file was open, it's closed (and 'Fplt' rsrc 
  55.                                                     // disappears, never to be called again)
  56.                                                     // if 'Fplt' file was closed, 'Fplt' handle is DisposeHandle-d.
  57.  
  58.         kFinderPopletContinue                        // Continue calling Fplt as normal...
  59. };
  60.  
  61. enum {    kCurrentFinderPopletVersion = 1 };
  62.  
  63. typedef struct {
  64.     UInt32                fpltVersion;                // version of FinderPoplet record
  65.     UInt32                fpltRefCon;                    // all yours - whatever you returned last time
  66.     EventRecord            *fpltEvent;                    // as passed to GNEFilterProc (*BUT* can be NULL!)
  67.     OSType                fpltCurrentProcessSig;        // for your convenience, sah!
  68.     ProcessSerialNumber    fpltCurrentProcessPSN;        // ditto
  69.     const AEDesc        *flptSelection;                // "inSelection" parameter to _ContextualMenuSelect (or NULL)
  70.     UInt32                fpltPrivate[2];                // private parts.
  71.     UInt32                fpltReserved[4];            // currently zeroed
  72. } TFinderPopletInfo;
  73.  
  74. typedef pascal UInt32 (*TFinderPopletProc)(TFinderPopletInfo *info);
  75.  
  76. enum {                                    // FinderPopAPIProc selectors
  77.                                         // 0 .. 8 private
  78.  
  79.     kFPPGetFinderPopActive = 9,            // <- 0 (off) .. 1 (on)
  80.     kFPPGetAutoPopupDelay,                // <- 0 (off) .. 120 ticks
  81.     kFPPSetAutoPopupDelay,                // -> 0 (off) .. 120 ticks
  82.     kFPPLaunchFinderPopletFile,            // -> FSSpec of some file containing 'Fplt'=128
  83.     kFPPLaunchFinderPopletHandle,        // -> Handle to TFinderPopletProc (in sysHeap, preferably :-)
  84.     kFPPGetVersion,                        // return FinderPop version (from 'vers')
  85. //    kFPPSetOKToAutoPopup,                // -> nonzero --> OK to autopopup, regardless of QD activity
  86.     kFPPIllegalSelector = -999
  87. };
  88.  
  89. #ifdef __cplusplus
  90. extern "C" {
  91. #endif
  92.  
  93. typedef struct OpaqueFinderPopCookie *TFinderPopCookie;
  94.  
  95. extern TFinderPopCookie OpenFinderPopConnection(void);
  96. extern TFinderPopCookie CloseFinderPopConnection(TFinderPopCookie theConnection);
  97.  
  98. extern SInt32 FinderPopAPIProc(TFinderPopCookie cookie, UInt32 selector, SInt32 param);
  99.  
  100. #ifdef __cplusplus
  101. }                        /* extern "C" */
  102. #endif
  103.  
  104. //
  105. // Accessors.
  106. //
  107.  
  108. #ifdef __cplusplus
  109.  
  110. inline Boolean IsFinderPopActive(TFinderPopCookie cookie) {
  111.     return FinderPopAPIProc(cookie, kFPPGetFinderPopActive, 0);
  112. }
  113. inline SInt32 GetFinderPopAutoPopupDelay(TFinderPopCookie cookie) {
  114.     return FinderPopAPIProc(cookie, kFPPGetAutoPopupDelay, 0);
  115. }
  116. inline OSErr SetFinderPopAutoPopupDelay(TFinderPopCookie cookie, unsigned int value0_127) {
  117.     return FinderPopAPIProc(cookie, kFPPSetAutoPopupDelay, value0_127);
  118. }
  119. inline OSErr LaunchFinderPopletFile(TFinderPopCookie cookie, const FSSpec *fsspecptr) {
  120.     return FinderPopAPIProc(cookie, kFPPLaunchFinderPopletFile, (SInt32)fsspecptr);
  121. }
  122. inline OSErr LaunchFinderPopletHandle(TFinderPopCookie cookie, Handle fpltHandle) {
  123.     return FinderPopAPIProc(cookie, kFPPLaunchFinderPopletHandle, (SInt32)fpltHandle);
  124. }
  125.  
  126. #else    /* horrible C preprocessor macros */
  127.  
  128. #define /*Bool*/    IsFinderPopActive(cookie)                                        \
  129.                         FinderPopAPIProc(cookie, kFPPGetFinderPopActive, 0)
  130. #define    /*int*/        GetFinderPopAutoPopupDelay(cookie)                                \
  131.                         FinderPopAPIProc(cookie, kFPPGetAutoPopupDelay, 0)
  132. #define    /*OSErr*/    SetFinderPopAutoPopupDelay(cookie, value0_127)                    \
  133.                         FinderPopAPIProc(cookie, kFPPSetAutoPopupDelay, value0_127)
  134. #define    /*OSErr*/    LaunchFinderPopletFile(cookie, fsspecptr)                    \
  135.                         FinderPopAPIProc(cookie, kFPPLaunchFinderPopletFile, (SInt32)fsspecptr)
  136. #define    /*OSErr*/    LaunchFinderPopletHandle(cookie, fpltHandle)                \
  137.                         FinderPopAPIProc(cookie, kFPPLaunchFinderPopletHandle, (SInt32)fpltHandle)
  138.  
  139. #endif    /* __cplusplus */
  140.  
  141. /*
  142.  Usage example:
  143.  
  144.      TFinderPopCookie finderPopCookie = OpenFinderPopConnection();
  145.  
  146.      if (finderPopCookie != 0)                // FP is installed
  147.      {
  148.         if (IsFinderPopActive(finderPopCookie))
  149.             printf("FinderPop is installed and active\n");
  150.         else
  151.             printf("FinderPop in installed but turned off\n");
  152.  
  153.         SInt32 fpAutoPopupDelay = GetFinderPopAutoPopupDelay(finderPopCookie);
  154.         (void)SetFinderPopAutoPopupDelay(finderPopCookie, 0);
  155.  
  156.         ...do something...
  157.  
  158.         (void)SetFinderPopAutoPopupDelay(finderPopCookie, fpAutoPopupDelay);
  159.  
  160.          finderPopCookie = CloseFinderPopConnection(finderPopCookie);
  161.     }
  162.  
  163. */
  164.  
  165. #if PRAGMA_ALIGN_SUPPORTED
  166. #pragma options align=reset
  167. #endif
  168.  
  169. #endif    /* __FinderPop__ */
  170.